﻿using Aweber;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Aweber.OAuth;
using System.Configuration;
using Aweber.Entity;

namespace UnitTests
{
    
    
    /// <summary>
    ///This is a test class for MockAdapterTest and is intended
    ///to contain all MockAdapterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MockAdapterTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MockAdapter Constructor
        ///</summary>
        [TestMethod()]
        public void MockAdapterConstructorTest()
        {
            MockAdapter target = new MockAdapter();

            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for BuildRequest
        ///</summary>
        [TestMethod()]
        public void BuildRequestTest()
        {
            MockAdapter target = new MockAdapter();
            Request expected = new Request();
            Request actual;
            actual = target.BuildRequest();

            Assert.AreEqual(expected.oauth_callback, actual.oauth_callback);
            Assert.AreEqual(expected.oauth_consumer_key, actual.oauth_consumer_key);
            Assert.AreEqual(expected.oauth_consumer_secret, actual.oauth_consumer_secret);
            Assert.AreEqual(expected.oauth_nonce, actual.oauth_nonce);
            Assert.AreEqual(expected.oauth_signature, actual.oauth_signature);
            Assert.AreEqual(expected.oauth_signature_method, actual.oauth_signature_method);
            Assert.AreEqual(expected.oauth_timestamp, actual.oauth_timestamp);
            Assert.AreEqual(expected.oauth_token, actual.oauth_token);
            Assert.AreEqual(expected.oauth_token_secret, actual.oauth_token_secret);
            Assert.AreEqual(expected.oauth_verifier, actual.oauth_verifier);
            Assert.AreEqual(expected.oauth_version, actual.oauth_version);
            Assert.AreEqual(expected.Parameters, actual.Parameters);

        }

        /// <summary>
        ///A test for GetResponse
        ///</summary>
        [TestMethod()]
        public void GetResponseTest()
        {
            // Get Response requires a build up of many objects to test it out against specific end points
            // Because every type of call that it makes is tested in other unit tests
            // It will not be tested here
        }

        /// <summary>
        ///A test for AppId
        ///</summary>
        [TestMethod()]
        public void AppIdTest()
        {
            MockAdapter target = new MockAdapter();
        
            string expected =  ConfigurationManager.AppSettings["AweberAppId"];
            string actual;
            target.AppId = expected;
            actual = target.AppId;
            Assert.AreEqual(expected, actual);
 
        }

        /// <summary>
        ///A test for CallbackUrl
        ///</summary>
        [TestMethod()]
        public void CallbackUrlTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "http://localhost";
            string actual;
            target.CallbackUrl = expected;
            actual = target.CallbackUrl;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ConsumerKey
        ///</summary>
        [TestMethod()]
        public void ConsumerKeyTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "Test Value";
            string actual;
            target.ConsumerKey = expected;
            actual = target.ConsumerKey;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ConsumerSecret
        ///</summary>
        [TestMethod()]
        public void ConsumerSecretTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "Test Value";
            string actual;
            target.ConsumerSecret = expected;
            actual = target.ConsumerSecret;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for OAuthToken
        ///</summary>
        [TestMethod()]
        public void OAuthTokenTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "Test Value";
            string actual;
            target.OAuthToken = expected;
            actual = target.OAuthToken;
            Assert.AreEqual(expected, actual);
          
        }

        /// <summary>
        ///A test for OAuthTokenSecret
        ///</summary>
        [TestMethod()]
        public void OAuthTokenSecretTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "Test Value";
            string actual;
            target.OAuthTokenSecret = expected;
            actual = target.OAuthTokenSecret;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for OAuthVerifier
        ///</summary>
        [TestMethod()]
        public void OAuthVerifierTest()
        {
            MockAdapter target = new MockAdapter();
            string expected = "Test Value";
            string actual;
            target.OAuthVerifier = expected;
            actual = target.OAuthVerifier;
            Assert.AreEqual(expected, actual);
        }
    }
}
